<jsp:useBean id="sessiondata" class="bibbletex.models.SessionData"
	scope="session" />

<%@ page
	import="bibbletex.models.*,java.util.UUID,java.util.List"
	import="bibbletex.views.CollaborationView,bibbletex.controllers.CollaborationController"
	import="bibbletex.helpers.BibtexFormat,bibbletex.helpers.BitlyHelper" %>	

<%!
	String page_title = new String("Invite people to collaborate");
	String onloadjsfunction = "";
	boolean show_title = true;
	String[] jstitle={"invite"};
	boolean show_navigation = true;
%>
<%
	String id_parameter = request.getParameter("cid");
	Collaboration c = null;
	
	if (id_parameter == null)
	{
		if (sessiondata.collaboration != null)
			c = sessiondata.collaboration;
	}
	else
	{
		c = CollaborationController.load(id_parameter);
		sessiondata.collaboration = c;
	}
	
%>
<%@ include file="/header.jsp"%>

<% if (c != null) { %>
<div id="Content">
	<div id="ContentCenter" class="clearfix">
	
	<div id="inviteContainer">
<div class="inviteLinks">
<h3>Share Direct Links</h3>
<%
			if (id_parameter == null
						|| sessiondata.collaboration_is_editable) { // We just created it so we show the links
		%>
		<p>
			<label for="publicLink">Public link:</label>
			<input name="publicLink" type="text" value="<%=BitlyHelper.shorten(c.getPublic_id())%>"/>
			<a class="fbshare" href="https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fbit.ly%2F<%=BitlyHelper.shorten(c.getPublic_id()).substring(14)%>"><img src="/img/content/fbshare.gif" /></a>
		</p><br />
		<p class="sharehint">Share this public link with your friends so they can suggest you new references.</p>
		<p class="sharehint sharehintmargin">Through this link they will not be able to change anything in your collaboration, only suggest you new references.</p>

		<%
			if (id_parameter == null
							&& sessiondata.collaboration_is_editable) {
		%>
		<p>
			<label for="privateLink">Private link:</label>
			<input name="privateLink" type="text" value="<%=BitlyHelper.shorten(c.getId().toString())%>" />
			<a class="fbshare2" href="https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fbit.ly%2F<%=BitlyHelper.shorten(c.getId().toString()).substring(14)%>"><img src="/img/content/fbshare.gif" /></a>
		</p><br />
		<p class="sharehint">Share this private link with your collaborators to give them complete access to your collaboration.</p>
		<p class="sharehint">You can also retrieve it from your email.</p>

		<%
			}
		%>
		<%
			}
		%>
</div>
<div class="inviteMail">
	<h3>Invite via E-Mail</h3>
	<form action="/collaboration/process.jsp" method="post">
<table id="emails">
	<tr>
		<td>E-Mail</td>
		<% if (sessiondata.collaboration_is_editable) { %>
		<td>Private</td>
		<% } %>
	<tr>
	<tr>
		<td><input type="email" name="email1" placeholder="friend@domain.com" /></td>
		
		<td><input type="checkbox" name="private1" <% if (!sessiondata.collaboration_is_editable) { %>style="display:none"<%}%> /></td>
		
	</tr>
</table>

<input type="button" value="+" onclick="addMail(<% if (sessiondata.collaboration_is_editable){ %>false<% } else{%>true<%}%>)"/>


	<div class="form-line submit-center">
		<input type="submit" value="Send Mail" />
	</div>

</form>
</div>
</div>
	
	
		

</div>
</div>

<% } else { %>

<div class="error">Unable to load Collaboration.
<br />Please Contact our Support.</div>


<% } %>

<%@ include file="/footer.jsp"%>
